<script setup>
//导入
import {ref,onMounted} from 'vue';
import axios from 'axios';
//创建空数据
const user = ref({
    name:'',
    gender:'',
    job:''
})
const EmpList=ref([])
//获取数据
const serach =async()=> {
    const result = await axios.get(`https://web-server.itheima.net/emps/list?name=${user.value.name}&gender=${user.value.gender}&job=${user.value.job}`)
    EmpList.value=result.data.data
}
const clean=()=>(
    user.value={name:'',gender:'',job:''},
    serach()
)
//构造函数
onMounted(() => {
    serach();
})

</script>
<template>
<el-form :inline="true" :model="user" class="demo-form-inline">
    <el-form-item label="姓名">
      <el-input v-model="user.name" placeholder="请输入姓名" clearable />
    </el-form-item>
    <el-form-item label="性别">
      <el-select
        v-model="user.gender"
        placeholder="请选择性别"
        clearable
      >
        <el-option label="男" value="1" />
        <el-option label="女" value="2" />
      </el-select>
    </el-form-item>
    <el-form-item label="工作">
      <el-select
        v-model="user.job"
        placeholder="请选择工作"
        clearable
      >
        <el-option label="班主任" value="1" />
        <el-option label="讲师" value="2" />
        <el-option label="学工主管" value="3" />
        <el-option label="教学主管" value="4" />
        <el-option label="咨询师" value="5" />
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="serach">查询</el-button>
      <el-button type="primary" @click="clean">清除</el-button>
    </el-form-item>
  </el-form>

  <el-table :data="EmpList" border style="width: 100%" align="center">
    <el-table-column prop="id" label="ID" width="180" align="center"/>
    <el-table-column prop="name" label="姓名" width="180" align="center"/>
    <el-table-column prop="image" label="头像" width="180" align="center">
        <template #default="scope">
            <img :src="scope.row.image" width="50px">
        </template>
    </el-table-column>
    <el-table-column prop="gender" label="性别" width="180" align="center">
        <template #default="scope">
            {{ scope.row.gender==1?'男':'女'}}
        </template>
    </el-table-column>
    <el-table-column prop="job" label="工作" width="180" align="center">
        <template #default="scope">
            <job v-if="scope.row.job==1">班主任</job>
            <job v-else-if="scope.row.job==2">讲师</job>
            <job v-else-if="scope.row.job==3">学工主管</job>
            <job v-else-if="scope.row.job==4">教学主管</job>
            <job v-else-if="scope.row.job==5">咨询师</job>
            <job v-else>其他</job>
        </template>
    </el-table-column>
    <el-table-column prop="entrydate" label="入职日期" width="180" align="center"/>
    <el-table-column prop="updatetime" label="修改日期" width="180" align="center"/>
  </el-table>
  <h1>01</h1>
  <div class="common-layout">
    <el-container>
      <el-header>Header</el-header>
      <el-main>Main</el-main>
    </el-container>
  </div>
  <h1>02</h1>
  <div class="common-layout">
    <el-container>
      <el-header>Header</el-header>
      <el-main>Main</el-main>
      <el-footer>Footer</el-footer>
    </el-container>
  </div>
  <h1>03</h1>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">Aside</el-aside>
      <el-main>Main</el-main>
      <el-aside width="200px">Aside</el-aside>
    </el-container>
  </div>
  <h1>04</h1>
  <div class="common-layout">
    <el-container>
      <el-header>Header</el-header>
      <el-container>
        <el-aside width="200px">Aside</el-aside>
        <el-main>Main</el-main>
      </el-container>
    </el-container>
  </div>
  <h1>05</h1>
  <div class="common-layout">
    <el-container>
      <el-header>Header</el-header>
      <el-container>
        <el-aside width="200px">Aside</el-aside>
        <el-container>
          <el-main>Main</el-main>
          <el-footer>Footer</el-footer>
        </el-container>
      </el-container>
    </el-container>
  </div>
  <h1>06</h1>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">Aside</el-aside>
      <el-container>
        <el-header>Header</el-header>
        <el-main>Main</el-main>
      </el-container>
    </el-container>
  </div>
  <h1>07</h1>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">Aside</el-aside>
      <el-container>
        <el-header>Header</el-header>
        <el-main>Main</el-main>
        <el-footer>Footer</el-footer>
      </el-container>
    </el-container>
  </div>
</template>
<style scoped>
</style>